package com.ncloud.chnl.service.impl;

import org.apache.log4j.LogManager;
import org.apache.log4j.Logger;
import org.springframework.beans.factory.annotation.Autowired;

import com.alibaba.dubbo.config.annotation.Service;
import com.alibaba.fastjson.JSONObject;
import com.ncloud.chnl.business.ChnlDepositBusiness;
import com.ncloud.chnl.service.ChnlDepositService;
import com.ncloud.common.enmus.ResultEnum;
import com.ncloud.common.exception.UserException;

@Service
public class ChnlDepositServiceImpl implements ChnlDepositService {
	
	private static final Logger logger = LogManager.getLogger(ChnlDepositServiceImpl.class);

	@Autowired
	private ChnlDepositBusiness despositBusiness;
	
	@Override
	public JSONObject insertChnlDeposit(Long chnlId,Long userId) {
		if(chnlId==null || chnlId<=0)
			throw new UserException(ResultEnum.PARAM_ERROR);
		// 调用business处理
		return despositBusiness.insertChnlDeposit(chnlId,userId);
	}

	@Override
	public JSONObject adjustChnlDeposit(JSONObject json) {
		if(!json.containsKey("actionCode") || !json.containsKey("chnlId"))
			throw new UserException(ResultEnum.PARAM_ERROR);
		return despositBusiness.adjustChnlDeposit(json);
	}

	@Override
	public JSONObject preAbateChnlDeposit(JSONObject json) {
		if(!json.containsKey("orderId") || !json.containsKey("value"))
			throw new UserException(ResultEnum.PARAM_ERROR);
		return despositBusiness.preAbateChnlDeposit(json);
	}

	@Override
	public JSONObject abateChnlDeposit(JSONObject json) {
		// TODO Auto-generated method stub
		return null;
	}
	
}
